Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment vars expansion and pre defined git hashes in the yaml #120

Merged
merged 6 commits into from
Dec 29, 2022

Conversation

feribg
Copy link
Contributor

@feribg feribg commented Nov 3, 2022

Describe your changes

Issue ticket number and link

Closes #116

Checklist before requesting a review

  • [ x ] I have performed a self-review of my code
  • [ x ] I have added thorough tests (when necessary).
  • [ ] I have added the right documentation (when needed). Product update? If yes, write one line about this update.

@@ -180,7 +180,8 @@ def test_docker_build_caches_pkg_installation(EXPORTER, config,
capture_output=True)

ls = out.stdout.decode()
expected = ('environment.yml\nfast-pipeline.tar.gz\n'

expected = ('env.yaml\nenvironment.yml\nfast-pipeline.tar.gz\n'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add two more tests?

let's check the content of the env.yaml, one when a user already has one (then the content should be the existing user values + the default ones) and another one when there is no user env.yaml and we create it

Copy link
Contributor Author

@feribg feribg Nov 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but can you please share some thoughts on how these test projects are created, it doesnt seem any of them uses a git repo etc ? and how do you go about editing the cases (ie keep the same test project but one case with the env file, one case with it being a repo, one case - the current setup, without needing 3 separate projects).

check=True,
capture_output=True)

env_contents = out.stdout.decode()
Copy link
Contributor Author

@feribg feribg Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edublancas this file only has {} as contents instead it should have build_time and the git placeholders it does have the build time locally pre sending to docker and not the placeholders but im kinda lost in all the indirection where is that stuff being injected / cleared.

until docker.py image = build_image the env.yaml from env_file_path has the correct build_time but is still missing the git values and then the env.yaml that results in the docker image is empty. You can put a breakpoint and see it shouldnt be (has build time, still doesnt have git data even though i added the git init and it's a repo now...) So im a bit out of ideas for now.

@edublancas edublancas merged commit 69963e8 into ploomber:master Dec 29, 2022
@edublancas
Copy link
Contributor

hey @feribg, I fixed and merged the PR. Please take the version in master for a spin and let me know if it works for you. If so, I'll make a release.

Note: I saw you had a build_time placeholder (apart from the git ones) in your logic, I deleted it because I believe that will never get executed as it is not defined as a default placeholder in ploomber. is that right?

@feribg
Copy link
Contributor Author

feribg commented Dec 29, 2022

@edublancas thanks i will take a look and try to use the master one and report back. Yes I just added that one but didnt end up implementing it the idea being is to act as a git hash if it's a git repo but I dont really need it, figured it might be useful.

@edublancas
Copy link
Contributor

great, I also released a new ploomber version that contains your changes.

@feribg
Copy link
Contributor Author

feribg commented Mar 22, 2023

@edublancas doesn't look like its working correctly.

env_default = EnvDict({}, path_to_here=Path(path_to_env).parent)

* {{git_hash}}: Ensure git is installed and git repository exists

>>> soopervisor.__version__
'0.9.1'

Seems like it keeps looking for .git for whatever reason and its a bit tricky to debug it in AWS batch.

the .env file in the container isn't the merged one it doesn't contain git and git_hash only the original values. Also any thoughts on having a env_name.env.yaml in that gets moved to the container instead of the env.yaml seems safer for prod vs local dev

@edublancas
Copy link
Contributor

Since ploomber implements the logic for expanding these values, it's possible to replicate this exclusively with ploomber, right? No AWS Batch, no docker.

Based on the error message, looks like there is a bug that's erroring because there is no repository, so probably we need to add some extra logic to ploomber that checks if those placeholders are defined already and skip checking for a git repository. Do you have time to submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Placeholders break soopervisor
2 participants